{extend name="../admin/common/base" /}
{block name="body"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            {include file="platformWechat/form" /}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="my_js"}
<script>
    layui.use(['element', 'admin', 'form'], function () {
        var element = layui.element
            , admin = layui.admin
            , $ = layui.$
            , form = layui.form;
        var laydate = layui.laydate;

        var id = '{$id}';
        admin.ajax('{:url('admin/platformWechat/read',array('id'=>$id))}','',function (data) {
            if (data.code == 1001) {
                var value = {};
                $.each(data.data,function(key,val) {
                    value[key] = val
                });
                form.val("form",value)
            } else {
                layer.msg(data.msg + '请联系管理员。');
            }
        },'','get');
        // form.verify({});
        form.on('submit(form)', function (data) {
            admin.ajax('{:url('admin/platformWechat/update',array('id'=>$id))}', data.field, function (data) {
                if (data.code == 1001) {
                    $('#layui-icon-refresh',parent.document).click();
                    layer.confirm(data.msg + ',是否继续修改?', {
                        icon: 3,
                        title: '提示',
                        btn: ['继续', '返回']
                    }, function (index) {
                        location.reload();
                    }, function () {
                        admin.closeSelf()
                    });
                } else {
                    layer.msg(data.msg);
                }
            },'','put');
        });
    });
</script>
{/block}